-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Apply schema check for Azure OpenAI client response #130
Conversation
@marikaner @deekshas8 I would appreciate your opinions for this PR, especially if you like the approach with Zod. I can see some potential refactorings and automation, but feel free to mention them as well. public api check is failing due to the generated zod schema. Unfortunately, we have to generate the schema at compile time to check types. Although we could infer new ts types from zod schema, there is AFAIK no way to create a zod schema at runtime from ts type probably because there is no type at js runtime. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally I am not opposed to the "response" classes itself, might make access to data more convenient. However, if I got it right we are checking the structure of all responses for each request (right?) I expected this to happen in the tests only, not in production. While I think it is not super expensive, I don't see a major benefit either.
packages/foundation-models/src/openai/openai-embedding-response.ts
Outdated
Show resolved
Hide resolved
packages/foundation-models/src/azure-openai/azure-openai-chat-completion-response.test.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Context
AI/gen-ai-hub-sdk-js-backlog#54.
Use Zod schema to type check OpenAI chat and embedding reponses at runtime.
Definition of Done